package com.twu.biblioteca.resources;

import com.twu.biblioteca.models.Movie;

import java.util.ArrayList;

/**
 * Created with IntelliJ IDEA.
 * User: arvind
 * Date: 11/10/13
 * Time: 4:02 PM
 * To change this template use File | Settings | File Templates.
 */
public class MovieList {

    private static MovieList instance=new MovieList();
    private static ArrayList<Movie> movieList;

    private MovieList(){loadMovies();}

    public static MovieList getInstance()
    {
        return instance;
    }

    private void loadMovies() {


        movieList=new ArrayList<Movie>();
        for(int i=0;i<15;i++)
        {
            String rating=""+((i+1)%10);
            if(i>10)
                rating="N/A";
            Movie movie=new Movie("Movie"+(i+1),(1998+i),"Director"+(i+1),rating);
            movieList.add(movie);
        }

    }


    public String getMoviesDetail() {

        StringBuffer response=new StringBuffer();
        response.append("Name\tYear\tDirector\tRating\n");

        for(Movie movie:movieList)
            response.append(movie.getMovieDetails());
        return response.toString();

    }

}
